package sg.edu.nus.iss.billing.datastore;

import java.util.Collection;
import java.util.List;

import sg.edu.nus.iss.billing.datastore.impl.Selector;

/**
 * <h2>Select objects from given collection, by predefined selector</h2>
 * 
 * Eg: Let's say we have a POJO object, named User, contains attributes: name,
 * age and the relevant set,get method And Let's say have an collection contains
 * User, now I just want that name is 'Wang' and the age is range in 10-30. This
 * selector will return matched records. Please refer to the default
 * implementation {@link Selector} for more details
 * 
 * @author Wang DaYong
 * 
 */
public interface ISelector {

	/**
	 * Select objects from given collection, by predefined selector
	 * 
	 * @param <T>
	 * @param list
	 *            The collection need to be filtered
	 * @return filtered list
	 * @throws Exception
	 *             when the compared field not implement from
	 *             java.lang.Comparable</br> when the methods name in Object in
	 *             list not apply to the POJO naming convention
	 */
	public <T extends Object> List<T> filter(Collection<T> list) throws Exception;
}
